﻿package mortal.game.view.mainUI.rightTop
{
    import __AS3__.vec.*;
    import com.mui.containers.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.systemSetting.*;
    import mortal.game.view.systemSetting.data.*;
    import mortal.game.view.systemSetting.view.*;
    import mortal.mvc.core.*;
    import mortal.mvc.events.*;

    public class QuickHideSetPanel extends View
    {
        private var _bg:ScaleBitmap;
        private var _settingItems:Array;
        private var _itemBox:GBox;
        private var _vecSettingItem:Vector.<SystemSetItem>;
        private var _isSelectAll:Boolean = false;
        private var _itemSelectAll:GCheckBox;
        private var _itemSelectQuality:GCheckBox;
        private static var _instance:QuickHideSetPanel;

        public function QuickHideSetPanel()
        {
            this._vecSettingItem = new Vector.<SystemSetItem>;
            mouseEnabled = true;
            this.layer = LayerManager.toolTipLayer;
            return;
        }// end function

        override protected function configUI() : void
        {
            this._settingItems = new Array();
            this._settingItems.push(SystemSetting.instance.hideSetter);
            this._settingItems.push(SystemSetting.instance.isHideSkill);
            this._settingItems.push(SystemSetting.instance.isHideTitle);
            this.addEventListener(ViewEvent.Show, this.onShow);
            super.configUI();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_3:SystemSetItem = null;
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(0, 0, 213, 133, this, ImagesConst.TipsBg);
            this._itemBox = UICompomentPool.getUICompoment(GBox) as GBox;
            UIFactory.setObjAttri(this._itemBox, 36, 25, -1, -1, this);
            this._itemBox.direction = GBoxDirection.VERTICAL;
            var _loc_1:* = this._settingItems.length;
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1)
            {
                
                _loc_3 = UICompomentPool.getUICompoment(SystemSetItem);
                _loc_3.data = this._settingItems[_loc_2] as SettingItem;
                _loc_3.configEventListener(Event.CHANGE, this.onChangeItem);
                this._itemBox.addChild(_loc_3);
                this._vecSettingItem.push(_loc_3);
                _loc_2++;
            }
            this._itemBox.resetPosition2();
            return;
        }// end function

        protected function onSelectAllChange(event:Event) : void
        {
            var _loc_2:* = this._settingItems.length;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2)
            {
                
                (this._settingItems[_loc_3] as SettingItem).displayValue = this._itemSelectAll.selected ? (1) : (0);
                _loc_3++;
            }
            this.updateSelect();
            this.save();
            this._isSelectAll = this._itemSelectAll.selected;
            return;
        }// end function

        protected function onSelectQualityChange(event:Event) : void
        {
            if (this._itemSelectQuality.selected)
            {
                SystemSetting.instance.effectSetterType.displayValue = 1;
            }
            else
            {
                SystemSetting.instance.effectSetterType.displayValue = 4;
            }
            this.save();
            return;
        }// end function

        protected function onChangeItem(event:Event) : void
        {
            this.save();
            return;
        }// end function

        protected function save() : void
        {
            SystemSetting.instance.updateToServer();
            SystemSetting.instance.save();
            return;
        }// end function

        public function onShow(event:ViewEvent) : void
        {
            this.updateSelect();
            return;
        }// end function

        public function updateSelect() : void
        {
            var _loc_3:SystemSetItem = null;
            var _loc_1:* = this._vecSettingItem.length;
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1)
            {
                
                _loc_3 = this._vecSettingItem[_loc_2];
                _loc_3.data = this._settingItems[_loc_2] as SettingItem;
                _loc_2++;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._bg = null;
            this._itemBox.dispose(param1);
            this._itemBox = null;
            if (this._itemSelectAll)
            {
                this._itemSelectAll.dispose(param1);
                this._itemSelectAll = null;
            }
            if (this._itemSelectQuality)
            {
                this._itemSelectQuality.dispose(param1);
                this._itemSelectQuality = null;
            }
            this._vecSettingItem = new Vector.<SystemSetItem>;
            return;
        }// end function

        public static function get instance() : QuickHideSetPanel
        {
            if (!_instance)
            {
                _instance = new QuickHideSetPanel;
            }
            return _instance;
        }// end function

    }
}
